﻿using Little.Soldier.SWIFT;
using Little.Soldier.SWIFT.Definition;
using System;
using System.ComponentModel;
using System.Globalization;
using System.Text;

namespace Little.Soldier.SWIFT.Messages.Category0
{
  public class MTS23 : SwiftMessage
  {
    private static SwiftMessageDefinition MessageDefinition;
    private static SwiftTagDefinition U0002;
    private static SwiftTagSubItemDefinition U0003;
    private static SwiftTagDefinition U0004;
    private static SwiftTagSubItemDefinition U0005;
    private static SwiftTagDefinition U0006;
    private static SwiftTagSubItemDefinition U0007;
    private static SwiftTagDefinition U0008;
    private static SwiftTagSubItemDefinition U000E;
    private static SwiftTagSubItemDefinition U000F;
    private static SwiftTagDefinition U0010;
    private static SwiftTagSubItemDefinition U0011;
    private static SwiftTagDefinition U0012;
    private static SwiftTagSubItemDefinition U0013;
    private static SwiftTagDefinition U0014;
    private static SwiftTagSubItemDefinition U0015;
    private static SwiftTagDefinition U0016;
    private static SwiftTagChoiceDefinition U0017;
    private static SwiftTagDefinition U0018;
    private static SwiftTagSubItemDefinition U0019;
    private static SwiftTagSubItemDefinition U001A;
    private static SwiftTagSubItemDefinition U001B;
    private static SwiftTagSubItemDefinition U001C;
    private static SwiftTagSubItemDefinition U001D;
    private static SwiftTagSubItemDefinition U001E;
    private static SwiftTagSubItemDefinition U001F;
    private static SwiftTagSubItemDefinition U007F;
    private static SwiftTagDefinition U0080;
    private static SwiftTagSubItemDefinition U0081;
    private static SwiftTagSubItemDefinition U0082;
    private static SwiftTagSubItemDefinition U0083;
    private static SwiftTagSubItemDefinition U0084;
    private static SwiftTagSubItemDefinition U0086;
    private static SwiftTagSubItemDefinition U0087;

    [Description("Application Identifier")]
    public MTS23.Tag101 ApplicationIdentifier_101
    {
      get
      {
        return new MTS23.Tag101((SwiftElement) this, 0, (SwiftDefinitionElement) MTS23.U0002);
      }
    }

    [Description("Application Identifier")]
    public MTS23.Tag101 Tag101_ApplicationIdentifier
    {
      get
      {
        return this.ApplicationIdentifier_101;
      }
    }

    [Description("System Authentication")]
    public Tag502 SystemAuthentication_502
    {
      get
      {
        return new Tag502((SwiftElement) this, 0, (SwiftDefinitionElement) MTS23.U0004);
      }
    }

    [Description("System Authentication")]
    public Tag502 Tag502_SystemAuthentication
    {
      get
      {
        return this.SystemAuthentication_502;
      }
    }

    [Description("Session Number")]
    public Tag151 SessionNumber_151
    {
      get
      {
        return new Tag151((SwiftElement) this, 0, (SwiftDefinitionElement) MTS23.U0006);
      }
    }

    [Description("Session Number")]
    public Tag151 Tag151_SessionNumber
    {
      get
      {
        return this.SessionNumber_151;
      }
    }

    [Description("Date Time")]
    public Tag177 DateTime_177
    {
      get
      {
        return new Tag177((SwiftElement) this, 0, (SwiftDefinitionElement) MTS23.U0008);
      }
    }

    [Description("Date Time")]
    public Tag177 Tag177_DateTime
    {
      get
      {
        return this.DateTime_177;
      }
    }

    [Description("Window Size")]
    public MTS23.Tag110 WindowSize_110
    {
      get
      {
        return new MTS23.Tag110((SwiftElement) this, 0, (SwiftDefinitionElement) MTS23.U0010);
      }
    }

    [Description("Window Size")]
    public MTS23.Tag110 Tag110_WindowSize
    {
      get
      {
        return this.WindowSize_110;
      }
    }

    [Description("LT select state")]
    public Tag204 SelectState_204
    {
      get
      {
        return new Tag204((SwiftElement) this, 0, (SwiftDefinitionElement) MTS23.U0012);
      }
    }

    [Description("LT select state")]
    public Tag204 Tag204_SelectState
    {
      get
      {
        return this.SelectState_204;
      }
    }

    [Description("LT-directed queue")]
    public Tag208 LTDirectedQueue_208
    {
      get
      {
        return new Tag208((SwiftElement) this, 0, (SwiftDefinitionElement) MTS23.U0014);
      }
    }

    [Description("LT-directed queue")]
    public Tag208 Tag208_LTDirectedQueue
    {
      get
      {
        return this.LTDirectedQueue_208;
      }
    }

    [Description("Delivery subset List")]
    public Tag338 DeliverySubsetList_338
    {
      get
      {
        return new Tag338((SwiftElement) this, 0, (SwiftDefinitionElement) MTS23.U0016);
      }
    }

    [Description("Delivery subset List")]
    public Tag338 Tag338_DeliverySubsetList
    {
      get
      {
        return this.DeliverySubsetList_338;
      }
    }

    [Description("Previous Session Info")]
    public MTS23.Tag333 PreviousSessionInformation_333
    {
      get
      {
        return new MTS23.Tag333((SwiftElement) this, 0, (SwiftDefinitionElement) MTS23.U0018);
      }
    }

    [Description("Previous Session Info")]
    public MTS23.Tag333 Tag333_PreviousSessionInformation
    {
      get
      {
        return this.PreviousSessionInformation_333;
      }
    }

    [Description("Current Session Info")]
    public Tag330 CurrentSessionInformation_330
    {
      get
      {
        return new Tag330((SwiftElement) this, 0, (SwiftDefinitionElement) MTS23.U0080);
      }
    }

    [Description("Current Session Info")]
    public Tag330 Tag330_CurrentSessionInformation
    {
      get
      {
        return this.CurrentSessionInformation_330;
      }
    }

    public MTS23()
      : base(true)
    {
    }

    public MTS23(SwiftMessage message)
      : base(message)
    {
    }

    internal override SwiftMessageDefinition MsgDefinition()
    {
      return MTS23.MessageDefinition;
    }

    protected override void InitSwiftMessageDefinition()
    {
      MTS23.MessageDefinition = new SwiftMessageDefinition("MTS23", "Acknowledgement of a Select Request (SAK)");
      MTS23.U0002 = new SwiftTagDefinition("ApplicationIdentifier_101", "Application Identifier");
      MTS23.U0002.TagName = "{101:";
      MTS23.U0003 = new SwiftTagSubItemDefinition("ApplicationIdentifier", "Application Identifier");
      MTS23.U0002.Elements.Add((SwiftDefinitionElement) MTS23.U0003);
      MTS23.MessageDefinition.Elements.Add((SwiftDefinitionElement) MTS23.U0002);
      MTS23.U0004 = new SwiftTagDefinition("SystemAuthentication_502", "System Authentication");
      MTS23.U0004.TagName = "{502:";
      MTS23.U0005 = new SwiftTagSubItemDefinition("SystemAuthentication", "System Authentication");
      MTS23.U0004.Elements.Add((SwiftDefinitionElement) MTS23.U0005);
      MTS23.MessageDefinition.Elements.Add((SwiftDefinitionElement) MTS23.U0004);
      MTS23.U0006 = new SwiftTagDefinition("SessionNumber_151", "Session Number");
      MTS23.U0006.TagName = "{151:";
      MTS23.U0007 = new SwiftTagSubItemDefinition("SessionNumber", "Session Number");
      MTS23.U0006.Elements.Add((SwiftDefinitionElement) MTS23.U0007);
      MTS23.MessageDefinition.Elements.Add((SwiftDefinitionElement) MTS23.U0006);
      MTS23.U0008 = new SwiftTagDefinition("DateTime_177", "Date Time");
      MTS23.U0008.TagName = "{177:";
      MTS23.U000E = new SwiftTagSubItemDefinition("Date", "Date");
      MTS23.U0008.Elements.Add((SwiftDefinitionElement) MTS23.U000E);
      MTS23.U000F = new SwiftTagSubItemDefinition("Time", "Time");
      MTS23.U0008.Elements.Add((SwiftDefinitionElement) MTS23.U000F);
      MTS23.MessageDefinition.Elements.Add((SwiftDefinitionElement) MTS23.U0008);
      MTS23.U0010 = new SwiftTagDefinition("WindowSize_110", "Window Size");
      MTS23.U0010.TagName = "{110:";
      MTS23.U0011 = new SwiftTagSubItemDefinition("WindowSize", "Window Size");
      MTS23.U0010.Elements.Add((SwiftDefinitionElement) MTS23.U0011);
      MTS23.MessageDefinition.Elements.Add((SwiftDefinitionElement) MTS23.U0010);
      MTS23.U0012 = new SwiftTagDefinition("SelectState_204", "LT select state");
      MTS23.U0012.TagName = "{204:";
      MTS23.U0013 = new SwiftTagSubItemDefinition("SelectState", "Select State");
      MTS23.U0012.Elements.Add((SwiftDefinitionElement) MTS23.U0013);
      MTS23.MessageDefinition.Elements.Add((SwiftDefinitionElement) MTS23.U0012);
      MTS23.U0014 = new SwiftTagDefinition("LTDirectedQueue_208", "LT-directed queue");
      MTS23.U0014.TagName = "{208:";
      MTS23.U0015 = new SwiftTagSubItemDefinition("LTDirectedQueue", "LT-directed queue");
      MTS23.U0014.Elements.Add((SwiftDefinitionElement) MTS23.U0015);
      MTS23.MessageDefinition.Elements.Add((SwiftDefinitionElement) MTS23.U0014);
      MTS23.U0016 = new SwiftTagDefinition("DeliverySubsetList_338", "Delivery subset List");
      MTS23.U0016.TagName = "{338:";
      MTS23.U0016.Mandatory = false;
      MTS23.MessageDefinition.Elements.Add((SwiftDefinitionElement) MTS23.U0016);
      MTS23.U0017 = new SwiftTagChoiceDefinition("Choice", "");
      MTS23.U0017.Multiple = true;
      MTS23.U0018 = new SwiftTagDefinition("PreviousSessionInformation_333", "Previous Session Info");
      MTS23.U0018.TagName = "{333:";
      MTS23.U0019 = new SwiftTagSubItemDefinition("DateLastSessionOpened", "Date Last Session Opened");
      MTS23.U0018.Elements.Add((SwiftDefinitionElement) MTS23.U0019);
      MTS23.U001A = new SwiftTagSubItemDefinition("TimeLastSessionOpened", "Time Last Session Opened");
      MTS23.U0018.Elements.Add((SwiftDefinitionElement) MTS23.U001A);
      MTS23.U001B = new SwiftTagSubItemDefinition("SessionNumber", "Session Number");
      MTS23.U0018.Elements.Add((SwiftDefinitionElement) MTS23.U001B);
      MTS23.U001C = new SwiftTagSubItemDefinition("DateLastSessionClosed", "Date Last Session Closed");
      MTS23.U0018.Elements.Add((SwiftDefinitionElement) MTS23.U001C);
      MTS23.U001D = new SwiftTagSubItemDefinition("TimeLastSessionClosed", "Time Last Session Closed");
      MTS23.U0018.Elements.Add((SwiftDefinitionElement) MTS23.U001D);
      MTS23.U001E = new SwiftTagSubItemDefinition("ErrorCode", "Reason for closure");
      MTS23.U0018.Elements.Add((SwiftDefinitionElement) MTS23.U001E);
      MTS23.U001F = new SwiftTagSubItemDefinition("ISN", "Input Sequence Number.");
      MTS23.U0018.Elements.Add((SwiftDefinitionElement) MTS23.U001F);
      MTS23.U007F = new SwiftTagSubItemDefinition("OSN", "Output Sequence Number");
      MTS23.U0018.Elements.Add((SwiftDefinitionElement) MTS23.U007F);
      MTS23.U0017.Elements.Add((SwiftDefinitionElement) MTS23.U0018);
      MTS23.U0080 = new SwiftTagDefinition("CurrentSessionInformation_330", "Current Session Info");
      MTS23.U0080.TagName = "{330:";
      MTS23.U0081 = new SwiftTagSubItemDefinition("SessionNumber", "Session Number");
      MTS23.U0080.Elements.Add((SwiftDefinitionElement) MTS23.U0081);
      MTS23.U0082 = new SwiftTagSubItemDefinition("ISN", "Input Sequence Number.");
      MTS23.U0080.Elements.Add((SwiftDefinitionElement) MTS23.U0082);
      MTS23.U0083 = new SwiftTagSubItemDefinition("ISNNAK", "Session information - Identifies last Input NAK of previous session.");
      MTS23.U0080.Elements.Add((SwiftDefinitionElement) MTS23.U0083);
      MTS23.U0084 = new SwiftTagSubItemDefinition("OSN", "Output Sequence Number");
      MTS23.U0080.Elements.Add((SwiftDefinitionElement) MTS23.U0084);
      MTS23.U0086 = new SwiftTagSubItemDefinition("OSNNAK", "Session information - Identifies last Output NAK of previous session.");
      MTS23.U0080.Elements.Add((SwiftDefinitionElement) MTS23.U0086);
      MTS23.U0087 = new SwiftTagSubItemDefinition("ACKReplayIndicator", "Session information - Indicates the last ACK can be replayed.");
      MTS23.U0080.Elements.Add((SwiftDefinitionElement) MTS23.U0087);
      MTS23.U0017.Elements.Add((SwiftDefinitionElement) MTS23.U0080);
      MTS23.MessageDefinition.Elements.Add((SwiftDefinitionElement) MTS23.U0017);
    }

    public class Tag101 : SwiftTagWrapper
    {
      public string Value
      {
        get
        {
          return this.GetValue();
        }
        set
        {
          this.SetValue("101", value);
        }
      }

      internal Tag101(SwiftElement parent, int index, SwiftDefinitionElement definition)
        : base(parent, index, definition)
      {
      }
    }

    public class Tag110 : SwiftTagWrapper
    {
      public string Value
      {
        get
        {
          return this.GetValue();
        }
        set
        {
          this.SetValue("110", value);
        }
      }

      internal Tag110(SwiftElement parent, int index, SwiftDefinitionElement definition)
        : base(parent, index, definition)
      {
      }
    }

    public class Tag333 : SwiftTagWrapper
    {
      public string Value
      {
        get
        {
          return this.GetValue();
        }
        set
        {
          this.SetValue("333", value);
        }
      }

      public DateTime DateLastSessionOpened
      {
        get
        {
          DateTime result = DateTime.MinValue;
          string str = this.Value;
          if (str != null && str.Length > 0)
            DateTime.TryParseExact(str.Length <= 6 ? str.Substring(0) : str.Substring(0, 6), "yyMMdd", (IFormatProvider) CultureInfo.CurrentCulture, DateTimeStyles.None, out result);
          return result;
        }
        set
        {
          int num1 = 0;
          int num2 = 6;
          StringBuilder stringBuilder = new StringBuilder();
          string str1 = this.Value ?? string.Empty;
          str1.PadLeft(num1, ' ');
          stringBuilder.Append(str1.Substring(0, num1));
          string str2 = string.Format("{0:yyMMdd}", (object) value);
          if (str2.Length > num2)
            str2 = str2.Substring(0, num2);
          if (str1.Length > num1 + num2)
            str2 = str2.PadLeft(num2, ' ');
          stringBuilder.Append(str2);
          if (str1.Length > num1 + num2)
            stringBuilder.Append(str1.Substring(num1 + num2));
          this.Value = ((object) stringBuilder).ToString();
        }
      }

      public DateTime DateLastSessionClosed
      {
        get
        {
          DateTime result = DateTime.MinValue;
          string str = this.Value;
          if (str != null && str.Length > 14)
            DateTime.TryParseExact(str.Length <= 20 ? str.Substring(14) : str.Substring(14, 6), "yyMMdd", (IFormatProvider) CultureInfo.CurrentCulture, DateTimeStyles.None, out result);
          return result;
        }
        set
        {
          int num1 = 14;
          int num2 = 6;
          StringBuilder stringBuilder = new StringBuilder();
          string str1 = this.Value ?? string.Empty;
          str1.PadLeft(num1, ' ');
          stringBuilder.Append(str1.Substring(0, num1));
          string str2 = string.Format("{0:yyMMdd}", (object) value);
          if (str2.Length > num2)
            str2 = str2.Substring(0, num2);
          if (str1.Length > num1 + num2)
            str2 = str2.PadLeft(num2, ' ');
          stringBuilder.Append(str2);
          if (str1.Length > num1 + num2)
            stringBuilder.Append(str1.Substring(num1 + num2));
          this.Value = ((object) stringBuilder).ToString();
        }
      }

      internal Tag333(SwiftElement parent, int index, SwiftDefinitionElement definition)
        : base(parent, index, definition)
      {
      }
    }
  }
}
